Technotes
QuickTime Teletext Component APIs
This Technical Note describes the Teletext component APIs. The Teletext component is included in the Video Startup extension which is part of the Apple Video Player software. The component provides a standard API for accessing the Teletext hardware available on the international and UK tuner cards. See Inside Macintosh: QuickTime and Inside Macintosh: QuickTime Components for further documentation.
Contents About Teletext Component APIsThe Apple international and UK tuner cards include Teletext decoding hardware. The hardware also includes an Teletext page cache (currently 512K, but this will change in the future). The Teletext decoder hardware automatically decodes each Teletext page as it is received by the TV tuner and places it in the page cache. The page cache can store up to 512 of the most recently received pages. Because most Teletext systems broadcast fewer than 512 pages, the page cache contains almost every available Teletext page. This provides immediate access to any page on the system.
Teletext Page DataThe Teletext page data consists of 25 lines of data, each containing 40 characters. Each character may be a visible text character, a graphics character, or a special control character. Control characters are used to set text color, text size, text or graphics mode, etc. Interpretation of the control codes is not terribly complex, but is beyond the scope of this document.The first eight characters of the first line do not contain any visible data. This area is used by some televisions to display the current page number. The last eight characters of the first line contain the current time. The last line is used to display Fastext information. If no Fastext information is available for the current page, the last line will contain spaces. Visible text characters are not encoded using standard Macintosh character encoding. The data may be displayed as-is using the special Teletext font, but when displaying it using any other font or when saving it to disk or the clipboard, the data must be converted to standard Macintosh ASCII encoding. Each page also contains a small amount of other information: Fastext page numbers if available, a local index page number if available, and the character set the page should be displayed with (i.e., English, German, etc.). Using Teletext Component APIsAccessing a Teletext PageThe general algorithm for accessing the Teletext pages is as follows:
If the page is being displayed to the user, the application should also update the time field (i.e., the last 8 characters of the first line) once every second.
Using the Teletext componentAll access to the Teletext information is handled by the Teletext component. The following code demonstrates how to find and open the Teletext component:
ComponentDescriptiontheDesc; FindNextComponent will return nil if the Teletext component does not exist or if the component has determined that the Teletext hardware does not exist. OpenComponent will return nil if the Teletext component has already been opened by another application.
When the application is finished using the component, it should close the component using the TeleText Component APIsTTGetFastextPagespascal ComponentResult TTGetFastextPages(ComponentInstance ci, short *pages); ci component instance pages pointer to an array of kTTFastextPages (4) page numbersReturns ttPageNotAvailErr if requested page is not yet in memory. Returns ttNoPageLinksErr if Fastext information is not available for this channel.This function returns the page numbers associated with the four colored Fastext links. Page number 0 is for the red link, page number 1 is for the green link, page number 2 is for the yellow link, and page number 3 is for the cyan link. There may be fewer than four Fastext items available for a given page. A page number of zero indicates that the Fastext link is not available for the current page.
TTGetLocalIndexPagepascal ComponentResult TTGetLocalIndexPage(ComponentInstance ci, short *page); ci component instance page pointer to a page numberReturns ttPageNotAvailErr if requested page is not yet in memory. Returns ttNoPageLinksErr if there is no local index page indicated for this page.This function returns the local index page for the current page. Some stations specify a local index page for each Teletext page transmitted. For example, all of the pages in the sports section might specify the sports index page as the local index page. In turn, the sports index page might specify the news index page as it's local index page. The local index page is generally associated with the "Index" or "i" button on a remote control. If no local index page is specified for a page, use page 100 as the index page.
TTGetPageFlagspascal ComponentResult TTGetPageFlags(ComponentInstance ci, long *flags); ci component instance flags pointer to a 32-bit flag wordReturns ttPageNotAvailErr if requested page is not yet in memory.This function returns various flags associated with the current page. Each of the flags is defined below:
kTTLangEnglish = 0
TTGetPageNumberpascal ComponentResult TTGetPageNumber(ComponentInstance ci, short *page, short *subpage); ci component instance page pointer to a page number subpage pointer to a subpage numberThis function returns the page and subpage numbers last requested using the TTRequestPage function.
TTIsBroadcastingpascal ComponentResult TTIsBroadcasting(ComponentInstance ci, Boolean *flag); ci component instance flag pointer to a Boolean flagThis function returns true if Teletext information is being broadcast on the current channel.
TTIsPageAvailablepascal ComponentResult TTIsPageAvailable(ComponentInstance ci, Boolean *available); ci component instance available pointer to a Boolean flagThis function returns true if the page requested using TTRequestPage has been received and placed in memory.
TTIsPageUpdatedpascal ComponentResult TTIsPageUpdated(ComponentInstance ci, Boolean *updated); ci component instance updated pointer to Boolean flagReturns ttPageNotAvailErr if requested page is not yet in memory.
This function returns
TTReadPagepascal ComponentResult TTReadPage(ComponentInstance ci, Ptr buffer); ci component instance buffer pointer to a 1000 byte page bufferReturns ttPageNotAvailErr if requested page is not yet in memory. Returns ttParamErr if the buffer pointer is nil .
This function reads an entire Teletext page into the specified buffer. The page must first be requested using the
TTReadLinepascal ComponentResult TTReadLine(ComponentInstance ci, Ptr buffer, short line, short startcol, short length); ci component instance buffer pointer to an appropriatly sized buffer line line number (0-24) startcol starting column number (0-39) length number of bytes to read (1-40)Returns ttPageNotAvailErr if requested page is not yet in memory. Returns ttParamErr if the buffer pointer is nil, or if any of the other parameters is out of range.This function reads a portion of a Teletext line and places it into the specified buffer.
TTRequestPagepascal ComponentResult TTRequestPage(ComponentInstance ci, short page, short subpage); ci component instance page page number (100-899) subpage subpage number (0-99)Returns ttPageNotAvailErr if requested page is not yet in memory. Returns ttParamErr if the page or subpage numbers is out of range.
This function tells the Teletext hardware to load the requested page into internal memory. Requesting a page is an asynchronous operation. If the page number is in the external page cache, the page will be loaded into memory almost immediately. If it is not in the external page cache, the page won't be loaded into memory until the page is transmitted again. Use the
TTResetpascal ComponentResult TTReset(ComponentInstance ci); ci component instanceThis function resets the Teletext hardware, clearing the external page cache and setting the requested page number to 100. This function should be called whenever the user changes channels.
Teletext Component Constants#define ttUnimpErr -2201 /* feature unimplemented */ Further Reference
Technotes Previous Technote | Contents | Next Technote |